#include<iostream>
#include <string>
#include <string.h>
#include <queue>
using namespace std;
typedef struct node{
    char data;
    struct node *lchild;
    struct node *rchild;
}BTNode;
typedef struct node *BTree;
BTree CreateBTree(char a[],int i);
void LevelOrder(BTree b);
int main()
{
	char c[1000];
	BTree b;
	int i,f=0;
	gets(c);
	for(i=0;c[i];i++)
	{
		if(c[i]!='#')
		{
			f=1;
			break;
		}
	}
	if(!f)
	cout<<"NULL";
	else{
		b= CreateBTree( c,1);
		LevelOrder( b);
	}
	
}
BTree CreateBTree(char a[],int i)
{
	BTree b;
	if(i>strlen(a))return NULL;
	if(a[i]=='#')return NULL;
	b=new BTNode;
	b->data=a[i];
	b->lchild=CreateBTree(a,2*i);
	b->rchild=CreateBTree(a,2*i+1);
	return b;
}
void LevelOrder(BTree b)
{
	static int flag=0;
	BTree p;
	queue<BTree> q;
	q.push(b);
	while(!q.empty())
	{
		p=q.front();
		q.pop();
		if(!flag)
		{
			cout<<p->data;
			flag=1;
		}
		else
		cout<<" "<<p->data;
		if(p->lchild!=NULL)
		q.push(p->lchild);
		if(p->rchild!=NULL)
		q.push(p->rchild);
	}
}
